package oakclub.cronjob;

import it.sauronsoftware.cron4j.Task;
import it.sauronsoftware.cron4j.TaskExecutionContext;
import oakclub.global.Container;
import oakclub.model.UserMappingModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BuildUserMappingJob extends Task
{
    public static String schedulingPattern = "0 3 * * *";
    private final Logger logger = LoggerFactory.getLogger(BuildUserMappingJob.class);

    public void execute(TaskExecutionContext context)
    {
        this.logger.info("BuildUserMappingJob");

        UserMappingModel userMappingModel = (UserMappingModel) Container.getComponent(UserMappingModel.class);
        try
        {
            userMappingModel.build();
        }
        catch(Exception e)
        {
            this.logger.warn("BuildUserMappingJob", e);
        }
    }
}
